package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduWorkOrder.EduWorkOrderKeyVO;
import com.jwsoft.manager.common.vo.eduWorkOrder.EduWorkOrderQueryVO;
import com.jwsoft.manager.common.vo.eduWorkOrder.EduWorkOrderVO;
import com.jwsoft.manager.common.vo.eduWorkOrderLog.EduWorkOrderLogVO;
import com.jwsoft.manager.core.integration.EduWorkOrderIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 工单表网关
 *
 * @author zhiyuan
 * @since 2023-02-24
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "工单表", description = "工单表")
public class EduWorkOrderController {

    @Autowired
    public EduWorkOrderIntegration eduWorkOrderIntegration;

    @Operation(summary = "客服工单表分页查询",description = "客服工单表分页查询")
    @PostMapping(value = "/workOrder0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> getList(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getList(vo));
    }

    @Operation(summary = "工单表根据主键查询详情",description = "工单表根据主键查询详情")
    @PostMapping(value = "/workOrder0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderVO> getById(@RequestBody @Validated EduWorkOrderKeyVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表新增",description = "工单表新增")
    @PostMapping(value = "/workOrder0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduWorkOrderVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表修改",description = "工单表修改")
    @PostMapping(value = "/workOrder0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduWorkOrderVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表删除",description = "工单表删除")
    @PostMapping(value = "/workOrder0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduWorkOrderKeyVO vo) {
        eduWorkOrderIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "技术人员工单处理分页查询",description = "技术人员工单处理分页查询")
    @PostMapping(value = "/workOrder0008", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> getWorkHandleList(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getWorkHandleList(vo));
    }

    @Operation(summary = "工单审核",description = "工单审核")
    @PostMapping(value = "/workOrder0009", produces = "application/json;charset=UTF-8")
    public AppResponse WorkOrderProcess(@RequestBody @Validated EduWorkOrderVO vo) {
        eduWorkOrderIntegration.WorkOrderProcess(vo);
        return AppResponse.successMsg("审核成功！");
    }

    @Operation(summary = "工单流转",description = "工单流转")
    @PostMapping(value = "/workOrder0010", produces = "application/json;charset=UTF-8")
    public AppResponse workOrderCirculation(@RequestBody @Validated EduWorkOrderLogVO vo) {
        eduWorkOrderIntegration.workOrderCirculation(vo);
        return AppResponse.successMsg("流转成功！");
    }

    @Operation(summary = "根据缓存获取序号",description = "根据缓存获取序号")
    @PostMapping(value = "/workOrder0011", produces = "application/json;charset=UTF-8")
    public AppResponse<Integer> getWorkNum(@RequestBody @Validated EduWorkOrderKeyVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getWorkNum(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "接单成功",description = "接单成功")
    @PostMapping(value = "/workOrder0012", produces = "application/json;charset=UTF-8")
    public AppResponse acceptOrder(@RequestBody @Validated EduWorkOrderKeyVO vo) {
        eduWorkOrderIntegration.acceptOrder(vo);
        return AppResponse.successMsg("接单成功！");
    }

    @Operation(summary = "学校工单表分页查询",description = "学校工单表分页查询")
    @PostMapping(value = "/workOrder0013", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> getListSchool(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getListSchool(vo));
    }

    @Operation(summary = "基教科工单处理分页查询",description = "基教科工单处理分页查询")
    @PostMapping(value = "/workOrder0014", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> gethandleWorkBasicEduDept(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.gethandleWorkBasicEduDept(vo));
    }

    @Operation(summary = "科长工单处理分页查询",description = "科长工单处理分页查询")
    @PostMapping(value = "/workOrder0015", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> gethandleWorkSectionChief(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.gethandleWorkSectionChief(vo));
    }

    @Operation(summary = "所有工单处理分页查询",description = "所有工单处理分页查询")
    @PostMapping(value = "/workOrder0016", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> getWorkOrderAll(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.getWorkOrderAll(vo));
    }

    @Operation(summary = "现场查询工单表分页查询",description = "现场查询工单表分页查询")
    @PostMapping(value = "/workOrder0017", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderVO>> workSubmitxcck(@RequestBody @Validated EduWorkOrderQueryVO vo) {
        return AppResponse.successData(eduWorkOrderIntegration.workSubmitxcck(vo));
    }
}
